<template>
  <div class="app-container">
    <div id="bar">
      <!--搜索、筛选-->
      <el-form
        :inline="true"
        class="demo-form-inline"
      >
        <el-form-item>
          <el-input
            v-model="filter_query.search"
            placeholder="搜索"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="search"
          >
            查询
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="add_collection"
          >
            添加
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div id="table">
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        element-loading-text="玩命加载中..."
      >
        <el-table-column
          prop="id"
          label="ID"
        />
        <el-table-column
          prop="name"
          label="项目名称"
        />
        <el-table-column
          prop="desc"
          label="描述"
          show-overflow-tooltip
        />
        <el-table-column
          prop="user"
          label="创建用户"
          show-overflow-tooltip
        />
        <el-table-column
          prop="host"
          label="测试环境"
          show-overflow-tooltip
        />
        <el-table-column
          prop="create_time"
          label="创建时间"
          show-overflow-tooltip
        />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="handle_edit(scope.row)"
            >
              编辑
            </el-button>
            <el-button
              size="mini"
              type="danger"
              @click="handle_delete(scope.row)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div id="edit">
      <el-dialog
        v-loading="loading"
        :title="dialog_title"
        :visible.sync="dialogFormVisible"
        element-loading-text="玩命加载中..."
      >
        <el-form :model="form">
          <el-form-item
            label="项目名称"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="form.name"
              style="width: 50%"
              placeholder="请输入参数名称"
            />
          </el-form-item>
          <el-form-item
            label="项目描述"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="form.desc"
              type="textarea"
              style="width: 50%"
              placeholder="请输入项目描述"
            />
          </el-form-item>
          <el-form-item
            label="项目域名"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="form.host"
              style="width: 50%"
              placeholder="请输入以http或https开头的域名"
            />
          </el-form-item>
        </el-form>
        <div
          slot="footer"
          class="dialog-footer"
        >
          <el-button @click="dialogFormVisible = false">
            取 消
          </el-button>
          <el-button
            type="primary"
            :loading="button_loading"
            @click="operate"
          >
            确 定
          </el-button>
        </div>
      </el-dialog>
    </div>
    <div id="pagination">
      <el-pagination
        :current-page="currentPage"
        :page-size="filter_query.limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { data, methods } from './index.zz'
export default {
  name: 'Project',
  data: data,
  mounted: function() {
    this.get_page_data()
  },
  methods: methods()
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

